package com.atguigu.gmall.order.rpc;/*
 * @author: XueYouPeng
 * @time: 23.7.28 下午 4:16
 */

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.common.result.ResultCodeEnum;
import com.atguigu.gmall.order.biz.OrderBizService;
import com.atguigu.gmall.order.entity.OrderInfo;
import com.atguigu.gmall.order.vo.OrderConfirmVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/api/inner/order")
public class OrderRpcController {

    @Autowired
    private OrderBizService orderBizService;

    @GetMapping(value = "/submitOrder")
    public Result<OrderConfirmVo> submitOrder(){
        OrderConfirmVo orderConfirmVo = orderBizService.submitOrder();
        return Result.build(orderConfirmVo , ResultCodeEnum.SUCCESS);
    }

    @GetMapping(value = "/findOrderInfo/{orderId}")
    public Result<OrderInfo> findOrderInfo(@PathVariable(value = "orderId") Long orderId) {
        OrderInfo orderInfo =  orderBizService.findOrderInfo(orderId) ;
        return Result.build(orderInfo , ResultCodeEnum.SUCCESS) ;
    }

    @PostMapping(value = "/saveOrderInfo")
    public Result<String> saveOrderInfo(@RequestBody OrderInfo orderInfo){
        String orderId = orderBizService.saveOrderInfo(orderInfo);
        return Result.build(orderId , ResultCodeEnum.SUCCESS) ;
    }
}
